package search;

import java.util.Scanner;

public class Poker {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] boxs=new int[n+1];
        int[] book=new int[n+1];
        dfs(1,boxs,book);
    }
    public static void dfs(int index,int[] boxs,int[] book){
        if(index==boxs.length){
            for(int i=1;i<boxs.length;i++){
                System.out.print(boxs[i]+" ");
            }
            System.out.println();
            return;
        }
        for(int i=1;i<boxs.length;i++){
            if(book[i]==0){
                book[i]=1;
                boxs[index]=i;
                dfs(index+1,boxs,book);
                book[i]=0;
            }
        }
    }
}
